import http.client
import urllib.parse
import json


def http_get(host, url):
    # print(host + url)
    conn = http.client.HTTPConnection(host)
    conn.request("GET", url)
    response = conn.getresponse()
    body_str = response.read().decode('utf-8')
    print(body_str)
    result = None
    if response.status == 200:
        result = json.loads(body_str)
    conn.close()
    return result


def main():
    query_string = urllib.parse.urlencode({"name": "some", "age": 30})
    response = http_get("localhost", "/api/?" + query_string)


if __name__ == '__main__':
    main()
